package mockrd;

import org.apache.log4j.Logger;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import scenic.MyLogger;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;


/**
 * Created by scenic on 2017/1/20.
 */
public class RDMock {
    private static Logger logger = MyLogger.get(RDMock.class);

    @Test
    public void test1(){
        MyList mock = mock(MyList.class);
        System.out.println( mock.size());

        when(mock.add(any())).then(invocation -> {
            logger.debug(invocation);
            logger.debug(Arrays.asList(invocation.getArguments()));
            logger.debug(invocation.getMethod());
            logger.debug(invocation.getMock());
            return null;
        });

//        doNothing().when(mock).testVoid();
        mock.add(1);
        mock.add(2);

//        when(mock).

        mock.testVoid();

        mock.size();

        verify(mock).size();

    }


    public static class MyList  extends ArrayList{
        public void testVoid(){
            logger.debug("call test void");
        }
    }

}
